<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		  content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
	<style>
		table.table>tbody>tr>td{
			vertical-align: middle;
		}
	</style>
	<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
	<!-- Brand and toggle get grouped for better mobile display -->
	<div class="navbar-header">
		<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
			<span class="sr-only">Toggle navigation</span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
		</button>
		<a class="navbar-brand" href="#">学生管理系统<sub>v1.0</sub></a>
	</div>

	<!-- Collect the nav links, forms, and other content for toggling -->
	<div class="collapse navbar-collapse navbar-ex1-collapse">
		<ul class="nav navbar-nav navbar-right">
			<li><a class="btn" href="#">登录</a></li>
			<li><a href="#">注册</a></li>
		</ul>
	</div><!-- /.navbar-collapse -->
</nav>
<div class="container">
	<div class="row">
		<div class="list-group col-xs-3 col-sm-3 col-md-3 col-lg-3">
			<a href="?c=entry" class="list-group-item">班级管理</a>
			<a href="?c=student" class="list-group-item active">学生管理</a>
		</div>
		<div class="panel panel-default col-xs-9 col-sm-9 col-md-9 col-lg-9">
			<div class="panel-body">
				<table class="table table-hover table-striped table-bordered table-condensed">
					<thead>
					<tr>
						<th>学生编号</th>
						<th>学生姓名</th>
						<th>学生性别</th>
						<th>学生年龄</th>
						<th>学生班级</th>
						<th>操作</th>
					</tr>
					</thead>
					<tbody>
						<?php foreach($data as $v):; ?>
						<tr>
							<td><?php echo $v['id'] ?></td>
							<td><?php echo $v['sname'] ?></td>
							<td><?php echo $v['sex'] ?></td>
							<td><?php echo $v['age'] ?></td>
							<td><?php echo $v['name'] ?></td>
							<td>
								<div class="btn-group btn-group-sm"><a href="?c=student&a=edit&id=<?php echo $v['id'] ?>" class="btn btn-primary">编辑</a><button onclick="del(<?php echo $v['id'] ?>)" data-toggle="modal" data-target="#myModal" class="btn btn-danger">删除</button>
								</div>
							</td>
						</tr>
						<?php endforeach; ?>
					</tbody>
				</table>
				<nav aria-label="Page navigation">
					<?php $page=isset($_GET['page'])?$_GET['page']:0; ?>
					<ul class="pagination">
						<?php if($page<=0){ ?>
						<li class="disabled">
								<span aria-hidden="true">&laquo;</span>
						</li>
						<?php }else{ ?>
							<li>
								<a href="?c=student&a=index&page=<?php echo $_GET['page']-1; ?>" aria-label="Previous">
									<span aria-hidden="true">&laquo;</span>
								</a>
							</li>
						<?php } ?>
						<?php for($i=0;$i<$count;$i++):; ?>
						<?php if($page==$i){ ?>
						<li class="active"><a href="?c=student&a=index&page=<?php echo $i ?>"><?php echo $i+1;?></a></li>
						<?php }else{ ?>
								<li><a href="?c=student&a=index&page=<?php echo $i ?>"><?php echo $i+1;?></a></li>
						<?php } ?>
						<?php endfor; ?>
						<?php if($page==($count-1)){ ?>
						<li class="disabled">
								<span aria-hidden="true">&raquo;</span>
						</li>
						<?php }else{ ?>
							<li>
								<a href="?c=student&a=index&page=<?php echo $page+1; ?>" aria-label="Next">
									<span aria-hidden="true">&raquo;</span>
								</a>
							</li>
						<?php } ?>
					</ul>
				</nav>
				<a href="?c=student&a=add" class="btn btn-primary">添加</a>
			</div>
			<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title" id="gridSystemModalLabel">警告</h4>
						</div>
						<div class="modal-body">
							<p>您确定删除数据？</p>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							<a href="?a=del&id=" type="button" class="btn btn-danger del">确定</a>
						</div>
					</div><!-- /.modal-content -->
				</div><!-- /.modal-dialog -->
			</div><!-- /.modal -->
		</div>
	</div>
</div>
<script>
    function del(id){
        $('.del').attr('href','?c=student&a=del&id='+id);
    }
</script>
</body>
</html>
